//
//  HNSH_ChatSendRedInputView.m
//  NongYe
//
//  Created by 李宇廷 on 2023/2/6.
//

#import "HNSH_ChatSendRedInputView.h"

@interface HNSH_ChatSendRedInputView ()

/* bgView */
@property (nonatomic, strong) UIView *bgView;

@end

@implementation HNSH_ChatSendRedInputView

- (instancetype)initWithFrame:(CGRect)frame {
    self = [super initWithFrame:frame];
    if (self) {
        self.backgroundColor = [UIColor whiteColor];
        [self configUI];
    }
    return self;
}

- (void)configUI {
    [self addAllViews];
    [self addAllLayout];
}

- (void)addAllViews {
    self.backgroundColor = [UIColor colorWithHexString:@"#F7F7F7"];
    [self addSubview:self.bgView];
    [self.bgView addSubview:self.imgV];
    [self.bgView addSubview:self.titleLabel];
    [self.bgView addSubview:self.desLabel];
    [self.bgView addSubview:self.textField];
    [self addSubview:self.bottomLabel];
    
}

- (void)addAllLayout {
    [self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(44);
        make.top.bottom.mas_equalTo(0);
    }];
    
    [self.desLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.mas_equalTo(-16);
        make.top.bottom.mas_equalTo(0);
    }];
    
    [self.textField mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.equalTo(self.desLabel.mas_left).offset(-8);
        make.width.mas_equalTo(150);
        make.top.bottom.mas_equalTo(0);
    }];
    
    [self.bottomLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(16);
        make.height.mas_equalTo(17);
        make.bottom.mas_equalTo(0);
    }];
}

#pragma mark lazy
- (UIView *)bgView {
    if (!_bgView) {
        _bgView = [[UIView alloc]initWithFrame:CGRectMake(16, 0, kScreenWidth-32, 52)];
        _bgView.backgroundColor = [UIColor whiteColor];
        _bgView.layer.cornerRadius = 8.0f;
        _bgView.layer.masksToBounds = YES;
    }
    return _bgView;
}

- (UIImageView *)imgV {
    if (!_imgV) {
        _imgV = [[UIImageView alloc]initWithFrame:CGRectMake(16, self.bgView.height/2-10, 20, 20)];
    }
    return _imgV;
}

- (UILabel *)titleLabel {
    if (!_titleLabel) {
        _titleLabel = [[UILabel alloc]init];
        _titleLabel.textColor = [UIColor colorWithHexString:@"#333333"];
        _titleLabel.font = [UIFont systemFontOfSize:16];
    }
    return _titleLabel;
}

- (UILabel *)desLabel {
    if (!_desLabel) {
        _desLabel = [[UILabel alloc]init];
        _desLabel.textColor = [UIColor colorWithHexString:@"#666666"];
        _desLabel.font = [UIFont systemFontOfSize:16];
    }
    return _desLabel;
}

- (UILabel *)bottomLabel {
    if (!_bottomLabel) {
        _bottomLabel = [[UILabel alloc]init];
        _bottomLabel.textColor = [UIColor colorWithHexString:@"#999999"];
        _bottomLabel.font = [UIFont systemFontOfSize:12];
    }
    return _bottomLabel;
}

- (UITextField *)textField {
    if (!_textField) {
        _textField = [[UITextField alloc]init];
        _textField.font = [UIFont systemFontOfSize:16];
        _textField.textColor = [UIColor colorWithHexString:@"#333333"];
        _textField.textAlignment = NSTextAlignmentRight;
        _textField.keyboardType = UIKeyboardTypeASCIICapableNumberPad;
    }
    return _textField;
}

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
